package com.weight.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSON;

import com.weight.common.enums.ResultEnum;

public class asdfs {
	@Autowired
//	private static UserLocationInfoService userLocationInfoService;
	public static void main(String[] args) {
//		Color.RED
		
		System.out.println(StringUtils.isBlank(null));
		
		System.out.println("111111111111111");
		System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
		
 
		try {
			System.out.println(DateUtils.parseDate("2018-01-01", "yyyy-MM-dd"));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		 
		 
		
		
//		DateUtils.getDateToString(Date date, String pattern ) {
//				 
//		DateUtils.getStringToDate
		
		
		
		
		
		
		
		
		
	   String ss="2018-05-09 17:40:56";
	   String ss2="2018-05-09 17:47:22";   
//       Date currentTime = new Date();
       SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//       String dateString = formatter.format(currentTime);
//       
//       
//       
//       try {
//    	   	System.out.println(formatter.parse(ss).getTime());
//    	   	System.out.println(formatter.parse(ss2).getTime());
//		} catch (ParseException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}  
       
       
       
       
       
//       ProjectInfoVO dd=new ProjectInfoVO();
//       
//       dd.setEndDate(new Date() );
//       dd.setProjInfoName("啊飒飒的");
//       
//       System.out.println(JSON.toJSONString(dd));
//       
//       String rrr="{\"endDate\":\"2018-06-09\",\"projInfoName\":\"啊飒飒的\"}";
//       System.out.println(JSON.parseObject(JSON.toJSONString(dd), ProjectInfoVO.class));
//       
//       System.out.println(JSON.parseObject(rrr, ProjectInfoVO.class));
       addALL();
		 
	}
	
//	public void ss(){
//		
//		
//		
//		
//		String str="[{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,"
//        		+ "\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,"
//        		+ "\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},"
//        		+ "{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":"
//        		+ "1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":"
//        		+ "117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":"
//        		+ "36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":"
//        		+ "1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":"
//        		+ "117.115907,\"time\":1525845057212},{\"lat\":36.65354,\"log\":117.115907,\"time\":1525845057212},{\"lat\":"
//        		+ "36.65354,\"log\":117.115907,\"time\":1525845057212}]";
//        
////        JSON.parse(str);
//        
//        System.out.println(JSON.parseArray(str));
//        
////        syso
////        JSONObject jsonObject = JSON.parseObject(JSON_OBJ_STR);
////        System.out.println(json.toString());  
//        List<UserLocationInfoVO> ssList= JSON.parseArray(str,UserLocationInfoVO.class);
//	 
//        System.out.println(ssList);
//	 
//        for(int k=0 ;k<ssList.size();k++) {
//			System.out.println(ssList.get(k));
//		}
//        String  userId="22316498";
//        List<UserLocationInfo> ulInfoList = new ArrayList<>();
//		for(UserLocationInfoVO usLoInfoVO:ssList) {
//			 if(usLoInfoVO!=null) {
//				 UserLocationInfo ulInfo=new UserLocationInfo();
//				 BeanUtils.copyProperties(usLoInfoVO,ulInfo);
//				 ulInfo.setUserInfoId(userId);
//				 ulInfo.setUserLocationInfoId(UUID.randomUUID().toString());
//				 ulInfo.setCreateBy(userId);
//				 ulInfo.setUpdateBy(userId);
//				 ulInfoList.add(ulInfo);
//			 } 
//		}
//		System.out.println(ulInfoList);
//		
//		
//		
//		
//		
//		
//		
//		
//		
//		
//		System.out.println(Color.RED);
//		
//		Behaviour sdfs = Color.BLANK;
//		sdfs.print();
//		sdfs.getInfo();
//		
//		 
//		System.out.println(ResultEnum.SUCCESS.getCode());
//		
//		
//		
//		
//		List<String> list = new ArrayList<String>();
//		  list.add("JavaWeb编程词典");        //向列表中添加数据
//		  list.add("Java编程词典");        //向列表中添加数据
//		  list.add("C#编程词典");         //向列表中添加数据
//		  list.add("ASP.NET编程词典");        //向列表中添加数据
//		  list.add("VC编程词典");         //向列表中添加数据
//		  list.add("SQL编程词典");        //向列表中添加数据
//		  Iterator<String> its = list.iterator();     //获取集合迭代器
//		  System.out.println("集合中所有元素对象：");
//		  int i=0;
//		  while (its.hasNext()) {        //循环遍历集合
//			  System.out.print(i+" "+its.next() + "  / ");     //输出集合内容
//			  i++;
//		  }
//		  List<String> subList = list.subList(3, 5);    //获取子列表
//		  System.out.println("\n截取集合中部分元素：");
//		  Iterator it = subList.iterator();
//		  while (it.hasNext()) {
//		   System.out.print(it.next() + "  / ");
//		  }
//		  System.out.println();
//		Date ss=new Date();
//		System.out.println(ss);
//		Date date = new Date();
//	    // 返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。
//	    long time = date.getTime();
//	    System.out.println(time);
//	        
//	}
//	CollectionUtils在真实项目中，是一个非常好用的工具类，使用非常频繁。它可以使代码更加简洁和安全。刚好在工作中利用这个工具类重构代码，顺便总结下分享分享:
//
//		并集
	
		public static void testUnion(){
		    String[] arrayA = new String[] { "阿萨", "B", "C", "D", "E", "F" };  
		    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
		    List<String> listA = Arrays.asList(arrayA);
		    List<String> listB = Arrays.asList(arrayB);
		    
		    System.out.println(CollectionUtils.union(listA, listB));
		    //2个数组取并集 
		    System.out.println(ArrayUtils.toString(CollectionUtils.union(listA, listB)));
		    //[A, B, C, D, E, F, G, H, K]
		}
		public static void addALL(){
//		    String[] arrayA = new String[] { "阿萨", "B", "C", "D", "E", "F" };  
//		    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
//		    List<String> listA = Arrays.asList(arrayA);
//		    List<String> listB = Arrays.asList(arrayB);
			
			 List<String> listA = new ArrayList<>();
			 listA.add("3");
			 listA.add("5");
			 listA.add("2");
			 List<String> listB = new ArrayList<>();
			 listB.add("1");
			 listB.add("5");
			 listB.add("0");
			 
			 CollectionUtils.addAll(listA, listB);
//		    listA.addAll(listB);
		    System.out.println(listA);
		    //2个数组取并集  
		    //[A, B, C, D, E, F, G, H, K]
		}
//		交集
	
		public void testIntersection(){
		    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
		    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
		    List<String> listA = Arrays.asList(arrayA);
		    List<String> listB = Arrays.asList(arrayB);
		    //2个数组取交集 
		    System.out.println(ArrayUtils.toString(CollectionUtils.intersection(listA, listB)));
		    //[B, D, F]

		}
//		交集的补集（析取）
	
		public void testDisjunction(){
		    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
		    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
		    List<String> listA = Arrays.asList(arrayA);
		    List<String> listB = Arrays.asList(arrayB);
		    //2个数组取交集 的补集
		    System.out.println(ArrayUtils.toString(CollectionUtils.disjunction(listA, listB)));
		    //[A, C, E, G, H, K]
		}
//		差集（扣除）
	
		public void testSubtract(){
		    String[] arrayA = new String[] { "A", "B", "C", "D", "E", "F" };  
		    String[] arrayB = new String[] { "B", "D", "F", "G", "H", "K" };
		    List<String> listA = Arrays.asList(arrayA);
		    List<String> listB = Arrays.asList(arrayB);
		    //arrayA扣除arrayB
		    System.out.println(ArrayUtils.toString(CollectionUtils.subtract(listA, listB)));
		    //[A, C, E]

		}
//		集合是否为空
	
		public void testIsEmpty(){

		    class Person{}
		    class Girl extends Person{}

		    List<Integer> first = new ArrayList<>();
		    List<Integer> second = null;
		    List<Person> boy = new ArrayList<>();
		    //每个男孩心里都装着一个女孩
		    boy.add(new Girl());
		    //判断集合是否为空
		    System.out.println(CollectionUtils.isEmpty(first));   //true
		    System.out.println(CollectionUtils.isEmpty(second));   //true
		    System.out.println(CollectionUtils.isEmpty(boy));   //false

		    //判断集合是否不为空
		    System.out.println(CollectionUtils.isNotEmpty(first));   //false
		    System.out.println(CollectionUtils.isNotEmpty(second));   //false
		    System.out.println(CollectionUtils.isNotEmpty(boy));   //true
		}
//		集合是否相等
	
		public void testIsEqual(){

		    class Person{}
		    class Girl extends Person{
		    }

		    List<Integer> first = new ArrayList<>();
		    List<Integer> second = new ArrayList<>();
		    first.add(1);
		    first.add(2);
		    second.add(2);
		    second.add(1);
		    Girl goldGirl = new Girl();
		    List<Person> boy1 = new ArrayList<>();
		    //每个男孩心里都装着一个女孩
		    boy1.add(new Girl());
		    List<Person> boy2 = new ArrayList<>();
		    //每个男孩心里都装着一个女孩
		    boy2.add(new Girl());
		    //比较两集合值
		    System.out.println(CollectionUtils.isEqualCollection(first,second));   //true
		    System.out.println(CollectionUtils.isEqualCollection(first,boy1));   //false
		    System.out.println(CollectionUtils.isEqualCollection(boy1,boy2));   //false

		    List<Person> boy3 = new ArrayList<>();
		    //每个男孩心里都装着一个女孩
		    boy3.add(goldGirl);
		    List<Person> boy4 = new ArrayList<>();
		    boy4.add(goldGirl);
		    System.out.println(CollectionUtils.isEqualCollection(boy3,boy4));   //true
		}
//		不可修改的集合
//		我们对c进行操作，s也同样获得了和c相同的内容，这样就可以避免其他人员修改这个s对象。有时候需要对它进行保护，避免返回结果被人修改。

	
		public void testUnmodifiableCollection(){
		    Collection<String> c = new ArrayList<>();
		    Collection<String> s = CollectionUtils.unmodifiableCollection(c);
		    c.add("boy");
		    c.add("love");
		    c.add("girl");
		    //! s.add("have a error");
		    System.out.println(s);
		}
}
